#include <ImageIO.h>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main( int argc, char *argv[] )
{
	cout << "ImageIO Test" << endl << "===============" << endl << endl;

	string filename;

	cout << "File: ";
	cin >> filename;
 
	string extension = filename.substr( filename.length( ) - 3 );
	for( int i = 0; i < extension.length( ); i++ ) extension[ i ] = tolower( extension[ i ] );


	if( extension == "tga" )
	{
		ImageIO::Image tgaImage;
		ImageIO::Result result = ImageIO::loadImage( &tgaImage, filename.c_str( ), ImageIO::TARGA );
		filename += ".bmp";
		ImageIO::writeImage( &tgaImage, filename.c_str( ), ImageIO::BITMAP );
	}
	else if( extension == "bmp" )
	{
		ImageIO::Image bmpImage;
		ImageIO::Result result = ImageIO::loadImage( &bmpImage, filename.c_str( ), ImageIO::BITMAP );
		filename += ".tga";
		ImageIO::writeImage( &bmpImage, filename.c_str( ), ImageIO::BITMAP );
	}


	return 0;
}

